package cn.iocoder.yudao.module.polling.dal.mysql.pollingtype;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.polling.controller.admin.pollingtype.vo.PollingTypeExportReqVO;
import cn.iocoder.yudao.module.polling.controller.admin.pollingtype.vo.PollingTypePageReqVO;
import cn.iocoder.yudao.module.polling.dal.dataobject.pollingtype.PollingTypeDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 巡检类型 Mapper
 *
 * @author 左达成
 */
@Mapper
public interface PollingTypeMapper extends BaseMapperX<PollingTypeDO> {

    default PageResult<PollingTypeDO> selectPage(PollingTypePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PollingTypeDO>()
                .eqIfPresent(PollingTypeDO::getRevision, reqVO.getRevision())
                .eqIfPresent(PollingTypeDO::getCreator, reqVO.getCreator())
                .betweenIfPresent(PollingTypeDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(PollingTypeDO::getUpdater, reqVO.getUpdater())
                .betweenIfPresent(PollingTypeDO::getUpdateTime, reqVO.getUpdateTime())
                .eqIfPresent(PollingTypeDO::getPtCode, reqVO.getPtCode())
                .likeIfPresent(PollingTypeDO::getPtName, reqVO.getPtName())
                .eqIfPresent(PollingTypeDO::getPtSymbol, reqVO.getPtSymbol())
                .eqIfPresent(PollingTypeDO::getPtPeriodValue, reqVO.getPtPeriodValue())
                .eqIfPresent(PollingTypeDO::getPtPeriodTitle, reqVO.getPtPeriodTitle())
                .eqIfPresent(PollingTypeDO::getPtRank, reqVO.getPtRank())
                .eqIfPresent(PollingTypeDO::getPtSystem, reqVO.getPtSystem())
                .eqIfPresent(PollingTypeDO::getPtState, reqVO.getPtState())
                .orderByDesc(PollingTypeDO::getId));
    }

    default List<PollingTypeDO> selectList(PollingTypeExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<PollingTypeDO>()
                .eqIfPresent(PollingTypeDO::getRevision, reqVO.getRevision())
                .eqIfPresent(PollingTypeDO::getCreator, reqVO.getCreator())
                .betweenIfPresent(PollingTypeDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(PollingTypeDO::getUpdater, reqVO.getUpdater())
                .betweenIfPresent(PollingTypeDO::getUpdateTime, reqVO.getUpdateTime())
                .eqIfPresent(PollingTypeDO::getPtCode, reqVO.getPtCode())
                .likeIfPresent(PollingTypeDO::getPtName, reqVO.getPtName())
                .eqIfPresent(PollingTypeDO::getPtSymbol, reqVO.getPtSymbol())
                .eqIfPresent(PollingTypeDO::getPtPeriodValue, reqVO.getPtPeriodValue())
                .eqIfPresent(PollingTypeDO::getPtPeriodTitle, reqVO.getPtPeriodTitle())
                .eqIfPresent(PollingTypeDO::getPtRank, reqVO.getPtRank())
                .eqIfPresent(PollingTypeDO::getPtSystem, reqVO.getPtSystem())
                .eqIfPresent(PollingTypeDO::getPtState, reqVO.getPtState())
                .orderByDesc(PollingTypeDO::getId));
    }

}
